<style>
    .tox-statusbar__branding { display: none; }
    .tox-form__grid.tox-form__grid--1col input { width: 400px!important; }
    .tox-form__grid.tox-form__grid--1col button { margin-top: 17px!important; }
</style>
<div class="{{$viewClass['form-group']}}">

    <label class="{{$viewClass['label']}} control-label">{!! $label !!}</label>

    <div class="{{$viewClass['field']}}">

        @include('admin::form.error')

        <textarea class="form-control {{$class}}" name="{{$name}}" placeholder="{{ $placeholder }}" {!! $attributes !!} >{{ $value }}</textarea>

        @include('admin::form.help-block')

    </div>
</div>

<script require="@tinymce" init="{!! $selector !!}">


    var opts = {!! admin_javascript_json($options) !!};

    opts.selector = '#'+id;

    //图片粘贴
    // opts.paste_retain_style_properties = "color font-size text-align font-weight font-family";
    opts.paste_enable_default_filters = false; // 关闭过滤器，否则从word复制的文档失去格式
    opts.plugins = 'paste,code,lists,link';
    opts.contextmenu = false; // 禁用编辑器的菜单
    // opts.contextmenu = "bold copy paste";

    if (! opts.init_instance_callback) {
        opts.init_instance_callback = function (editor) {
            editor.on('Change', function(e) {
                $this.val(String(e.target.getContent()).replace('<p><br data-mce-bogus="1"></p>', '').replace('<p><br></p>', ''));
            });
        }
    }

    // 删除每次产生的额外的p标签
    if (! opts.init_instance_callback) {
        opts.init_instance_callback = function (editor) {
            editor.on('Change', function(e) {
                $this.val(String(e.target.getContent()).replace('<p><br data-mce-bogus="1"></p>', '').replace('<p><br></p>', ''));
            });
        }
    }

    opts.font_formats = "微软雅黑='微软雅黑';宋体='宋体';黑体='黑体';仿宋='仿宋';楷体='楷体';隶书='隶书';幼圆='幼圆';Andale Mono=andale mono,times;Arial=arial,helvetica,sans-serif;Arial Black=arial black,avant garde;Book Antiqua=book antiqua,palatino;Comic Sans MS=comic sans ms,sans-serif;Courier New=courier new,courier;Georgia=georgia,palatino;Helvetica=helvetica;Impact=impact,chicago;Symbol=symbol;Tahoma=tahoma,arial,helvetica,sans-serif;Terminal=terminal,monaco;Times New Roman=times new roman,times;Trebuchet MS=trebuchet ms,geneva;Verdana=verdana,geneva;Webdings=webdings;Wingdings=wingdings";
    opts.toolbar = ['undo redo | preview | styleselect | fontselect | fontsizeselect| bold italic underline strikethrough forecolor backcolor | link blockquote removeformat codesample | alignleft aligncenter alignright  alignjustify| in…ullist numlist table subscript superscript | code']
    opts.setup = function(editor){
            editor.on('init',function (e) {
                this.getBody().style.fontFamily = '微软雅黑';

                // 前端统计字数
                // var init_length = countnums(editor.getContent());
                // var ele_h = '<span class="word_count  tox-statusbar__wordcount">'+init_length+'</span>';
                // var editor_id = editor.id;
                // var editor_app = $('#'+editor_id).parents('.form-group.row.form-field').find('.tox.tox-tinymce');
                // var parent = editor_app.find('.tox-statusbar__text-container');
                // parent.append(ele_h);

            }),
            // editor.on('click',function (e) {
            //     var html = editor.getContent();
            //     var content_length = countnums(html);
            //     var editor_id = editor.id;
            //     var editor_app = $('#'+editor_id).parents('.form-group.row.form-field').find('.tox.tox-tinymce');
            //     editor_app.find('.word_count').html(content_length);
            // }),
            editor.on('keyup',function(){
                editor.save();
                // 前端统计字数
                // var html = editor.getContent();
                // var content_length = countnums(html);
                // var editor_id = editor.id;
                // var editor_app = $('#'+editor_id).parents('.form-group.row.form-field').find('.tox.tox-tinymce');
                // editor_app.find('.word_count').html(content_length);

                if(typeof autoSave == 'function'){
                    // autoSave();
                }
            });
    };
    tinymce.init(opts)
</script>
